package mancala.ui;

import static mancala.Mancala.DEFAULT_STORE_STONE_COUNT;

import java.awt.Dimension;
import java.awt.Font;

import javax.swing.SwingConstants;

import mancala.model.Player;
import mancala.model.Store;


public class StoreImpl extends Store {

    private static final long serialVersionUID = 1L;
    Dimension minSize = new Dimension(110, 110);

    public StoreImpl(Player player) {
        setPlayer(player);
        setStones(DEFAULT_STORE_STONE_COUNT);

        setFont(new Font("Arial", Font.BOLD, 72));
        setHorizontalAlignment(SwingConstants.CENTER);
        setOpaque(false);
        int x = player.getId() == 1 ? 645 : 25;
        setLocation(x, 180);
        setSize(minSize);
    }

    @Override
    public Dimension getMinimumSize() {
        return minSize;
    }

    @Override
    public Dimension getPreferredSize() {
        return minSize;
    }

    @Override
    public String getText() {
        return Integer.toString(getStones());
    }

    @Override
    public String toString() {
        return "StoreImpl[player=" + getPlayer().getName() + ", stones=" + getStones() + "]";
    }
}